1
|
|
|
// Importers should always start with this |
2
|
|
|
var PassmanImporter = PassmanImporter || {}; |
|
|
|
|
3
|
|
|
(function(window, $, PassmanImporter) { |
4
|
|
|
'use strict'; |
5
|
|
|
// Define the importer |
6
|
|
|
PassmanImporter.passpackCsv = { |
7
|
|
|
info: { |
8
|
|
|
name: 'Passpack csv', |
9
|
|
|
id: 'passpackCsv', |
10
|
|
|
description: 'Go to Tools -> Export. Select Comma Separated Values, All entries then continue.' |
11
|
|
|
} |
12
|
|
|
}; |
13
|
|
|
|
14
|
|
|
PassmanImporter.passpackCsv.readFile = function (file_data) { |
|
|
|
|
15
|
|
|
return new C_Promise(function(){ |
|
|
|
|
16
|
|
|
var parsed_csv = PassmanImporter.readCsv(file_data, false); |
17
|
|
|
var credential_list = []; |
18
|
|
|
for (var i = 0; i < parsed_csv.length; i++) { |
19
|
|
|
var row = parsed_csv[i]; |
20
|
|
|
var _credential = PassmanImporter.newCredential(); |
21
|
|
|
_credential.label = row[0]; |
22
|
|
|
_credential.username = row[1]; |
23
|
|
|
_credential.password = row[2]; |
24
|
|
|
_credential.url = row[3]; |
25
|
|
|
var tags = row[4].split(' '); |
26
|
|
|
if (tags.length > 0) { |
27
|
|
|
_credential.tags = tags.map(function (item) { |
28
|
|
|
if (item) { |
|
|
|
|
29
|
|
|
return {text: item} |
|
|
|
|
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
}).filter(function (item) { |
33
|
|
|
return (item); |
34
|
|
|
}); |
35
|
|
|
} |
36
|
|
|
_credential.description = row[5]; |
37
|
|
|
_credential.email = row[6]; |
38
|
|
|
if (_credential.label) { |
39
|
|
|
credential_list.push(_credential); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
var progress = { |
43
|
|
|
percent: i/parsed_csv.length*100, |
44
|
|
|
loaded: i, |
45
|
|
|
total: parsed_csv.length |
46
|
|
|
}; |
47
|
|
|
|
48
|
|
|
this.call_progress(progress); |
49
|
|
|
} |
50
|
|
|
this.call_then(credential_list); |
51
|
|
|
}) |
|
|
|
|
52
|
|
|
}; |
53
|
|
|
})(window, $, PassmanImporter); |